<#include "common/common.html"/>
<meta charset="UTF-8">
<table
	     class="easyui-datagrid"   
	     id="datagrid"  
         title="意见管理"  
         url="${base}/feedback/list"
         toolbar="#searchtool,#toolbar" 
         pagination="true"
         rownumbers="true" 
         fitColumns="true"
         singleSelect="true"
         data-options="fit:false,border:false,pageSize:20,pageList:[5,10,15,20]" >  
    <thead>  
        <tr>
            <th field="id" width="5%" checkbox="true"></th>  
            <th field="names" width="5%">用户名</th>
            <th field="contact" width="10%">联系方式</th>
            <th field="contents" width="15%">意见内容</th>
            <th field="subType" width="5%">提交方式</th>
            <th field="ctime" width="15%">提出时间</th> 
            <th field="status" width="10%" formatter="formatStatus">状态</th>  
            <th field="accpUname" width="10%" >受理人</th> 
            <th field="description" width="10%"  formatter="formatSescription">备注</th> 
            <th field="accpTime" width="10%" >变更时间</th> 
            
                       
        </tr>  
    </thead>  
</table>  
<div id="searchtool" style="padding:5px"> 
      <span>开始时间:</span><input name="startTime" class="easyui-datebox" data-options="formatter:myformatter,parser:myparser" style="width:200px" >  
      <span>结束时间:</span><input name="endTime" class="easyui-datebox"  data-options="formatter:myformatter,parser:myparser" style="width:200px" >   
      <span>关键字:</span><input type="text" name="keyword" placeholder="用户名/手机号/意见内容" value="" size=20 />
      <a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-search" onclick="javascript:getQueryData();">搜索</a><br/>
      <span>认证状态:</span><input type="radio" name="status" value="" checked="checked" />全部 
                         <input type="radio" name="status" value="1" />已受理
                         <input type="radio" name="status" value="0" />未受理   
</div>  
<div id="toolbar">
        <a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-ok" plain="true" onclick="javascript:openEditDlg('受理','feedback/acceptData','feedback-dlg','feedback-fm');">受理</a>
        <a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-edit" plain="true" onclick="exportExcel()" >导出到EXCLE</a>
        <a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-edit" plain="true" onclick="javascript:openNewDlg('数据导入','','uploadExcel-dlg','uploadExcel-fm');">导入数据</a>
</div>
<div id="uploadExcel-dlg" class="easyui-dialog"  style="padding:10px 20px" closed="true" buttons="#dlg-buttons">
<form id="uploadExcel-fm"  method="post" enctype="multipart/form-data">  
   选择文件：　<input id="uploadExcel" name="uploadExcel" type="file"  style="width:200px" data-options="prompt:'请选择文件...'">  
       　　<a href="#" class="easyui-linkbutton" style="width:122px" onclick="uploadExcel()" >导入Excel</a> 　　     　　　　　      
</form> 
</div>

<div id="feedback-dlg" class="easyui-dialog"  style="padding:10px 20px" closed="true" buttons="#dlgfeedback-buttons">
        <form id="feedback-fm" method="post">
             <div class="fitem">
                <label>备注:</label>
                <input name="description" class="easyui-textbox" >
            </div>
        </form>
</div>
<div id="dlgfeedback-buttons">
    <a href="javascript:void(0)" id="saveBtn" class="easyui-linkbutton c6" iconCls="icon-ok" onclick="javascript:submitFeedback('feedback-dlg','feedback-fm')" style="width:90px">提交</a>
    <a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-cancel" onclick="javascript:$('#feedback-dlg').dialog('close')" style="width:90px">取消</a>
</div>

 

<script type="text/javascript">

function formatSescription(val,row,index){
      var value =val||'';
	  return "<lable  title='"+value+"'>"+value+"</lable";
}
function submitFeedback(dlgId,fmId){
	$("#"+fmId).form('submit',{
    url: url,
    onSubmit: function(){
       return $(this).form('validate');
    },
    success: function(result){
       var result = eval('('+result+')');
       $("#"+dlgId).dialog('close');   
           if (result.errorMsg){
        	   $.messager.alert('错误',result.errorMsg,'error');
        	   getQueryData();
           } else if(result.infoMsg){
        	   $.messager.alert('提示',result.infoMsg,'info');
        	   getQueryData();
           }else{
                   $('#datagrid').datagrid('reload');   
               }
                }
            });
        }
function getQueryData(){
	var keyWord = $("input[name='keyword']").val();
	var startTime = $("input[name='startTime']").val();
	startTime = startTime&&startTime+" 00:00:00";
	var endTime = $("input[name='endTime']").val();
	endTime = endTime&&endTime+" 23:59:59";
	var status = $("input[name='status']:checked").val();
	var queryData={
		keyword:keyWord,
		startTime:startTime,
		endTime:endTime,
		status:status
	};
	$('#datagrid').datagrid('load',queryData); 

}

$(document).ready(function() {
	$("input[name='status']").change(function(){
		getQueryData();
	});
});

function formatStatus(val){
	if (val == 1){
		return '已受理';
	} else {
		return '未受理';
	}
}



function authUser(){
	var rows = $('#datagrid').datagrid('getSelections');
	var status = rows[0].status;
	if(status==1){
		$.messager.alert('提示','该信息已受理','info');
		return false;
	}else{
		var url = "${base}/feedback/acceptData?status=1&id="+rows[0].id;
        $.post(url,function(result){
        	var result = eval('('+result+')');
        	if (result.errorMsg){
         	   $.messager.alert('错误',result.errorMsg,'error');
            } else if(result.infoMsg){
         	   $.messager.alert('提示',result.infoMsg,'info');  
         	   getQueryData();
            }else{
               $('#datagrid').datagrid('reload');   
            }
        });
		
		
	}
}




function exportExcel(){    
	var keyWord = $("input[name='keyword']").val();
	var startTime = $("input[name='startTime']").val();
	var endTime = $("input[name='endTime']").val();
	var status = $("input[name='status']:checked").val();
	var temp = "1=1";
	if(keyWord!=null){
		keyWord = encodeURI(keyWord);
		temp = temp+"&keyword="+keyWord
	}
	if(status!=null){
		temp = temp+"&status="+status
	}
	if(startTime!=null){
		temp = temp+"&startTime="+startTime
	}
	if(endTime!=null){
		temp = temp+"&endTime="+endTime
	}
	location.href="${base}/feedbackExcle/exportExcel?"+temp;       
} 





function uploadExcel(){   

				$.ajaxFileUpload({
					url : "${base}/feedbackExcle/uploadExcel",
					secureuri:false,
					fileElementId:"uploadExcel",
					dataType:"JSON",
					success : function(result) {
						getQueryData();
                    alert(result.substring(result.indexOf("|")+1,result.lastIndexOf("|")));

						
					}
				});
					  
				
					 
					 
					  //提交表单
/* 				    document.getElementById("uploadExcel-fm").action="${base}/avatarApis/fileUploads";  
					document.getElementById("uploadExcel-fm").submit();   
					$.messager.alert('提示','操作成功！','info');    */
	
				
			 }  


</script>